package CollectionDemo;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

public class Demo2 {
    public static void main(String[] args) {
        Collection<String>collection = new ArrayList<>();
        collection.add("aaa");
        collection.add("bbb");
        collection.add("ccc");
        //迭代器遍历
        Iterator<String> it = collection.iterator();
        while (it.hasNext()){
            String s = it.next();
            if(s.equals("ccc")){
                it.remove();
            }
        }
        System.out.println(collection);
    }
}
